package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.EquipUseView;
import com.ruoyi.system.service.IEquipUseViewService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 设备使用表Controller
 *
 * @author ruoyi
 * @date 2024-04-22
 */
@RestController
@RequestMapping("/system/equipUseView")
public class EquipUseViewController extends BaseController
{
    @Autowired
    private IEquipUseViewService equipUseViewService;

    /**
     * 查询设备使用表列表
     */
    @PreAuthorize("@ss.hasPermi('system:equipUseView:list')")
    @GetMapping("/list")
    public TableDataInfo list(EquipUseView equipUseView)
    {
        startPage();
        List<EquipUseView> list = equipUseViewService.selectEquipUseViewList(equipUseView);
        return getDataTable(list);
    }

    @Anonymous
    @GetMapping("/charts")
    public List<EquipUseView> charts(EquipUseView equipUseView){
        return equipUseViewService.selectEquipUseViewList(equipUseView);
    }

    /**
     * 导出设备使用表列表
     */
    @PreAuthorize("@ss.hasPermi('system:equipUseView:export')")
    @Log(title = "设备使用表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EquipUseView equipUseView)
    {
        List<EquipUseView> list = equipUseViewService.selectEquipUseViewList(equipUseView);
        ExcelUtil<EquipUseView> util = new ExcelUtil<EquipUseView>(EquipUseView.class);
        util.exportExcel(response, list, "设备使用表数据");
    }

    /**
     * 获取设备使用表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:equipUseView:query')")
    @GetMapping(value = "/{eId}")
    public AjaxResult getInfo(@PathVariable("eId") Long eId)
    {
        return success(equipUseViewService.selectEquipUseViewByEId(eId));
    }

    /**
     * 新增设备使用表
     */
    @PreAuthorize("@ss.hasPermi('system:equipUseView:add')")
    @Log(title = "设备使用表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EquipUseView equipUseView)
    {
        return toAjax(equipUseViewService.insertEquipUseView(equipUseView));
    }

    /**
     * 修改设备使用表
     */
    @PreAuthorize("@ss.hasPermi('system:equipUseView:edit')")
    @Log(title = "设备使用表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EquipUseView equipUseView)
    {
        return toAjax(equipUseViewService.updateEquipUseView(equipUseView));
    }

    /**
     * 删除设备使用表
     */
    @PreAuthorize("@ss.hasPermi('system:equipUseView:remove')")
    @Log(title = "设备使用表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{eIds}")
    public AjaxResult remove(@PathVariable Long[] eIds)
    {
        return toAjax(equipUseViewService.deleteEquipUseViewByEIds(eIds));
    }
}
